


#!/bin/bash




# 删除客户端主机指定路径下的文件，远程服务端主机会发生变化，但是会报错
#tail -f  /opt/test1.txt | while read line

# 使用管道符传递数据，但是后面接的是while read line命令
#inotifywait -mrq --format '%w%f  %e' -e delete,create,modify,close_write,move /data/rsync-data | awk '{print "rsync -avz "$1,"rsync_backup@192.168.68.146::backup"}' | while read line
inotifywait -mrq --format '%w%f' -e delete,create,modify,close_write,move /data/rsync-data | while read line
do
     #inotifywait -mrq --format '%w%f' -e delete,create,modify,close_write,move /data/rsync-data | awk '{print "rsync -avz "$1,"rsync_backup@192.168.68.146::backup"}' | while read line
     #echo  $line

     rsync -avz $line rsync_backup@192.168.68.146::backup

done
